var app = new Vue({
	el: '#app',
	data: {
		msg: '',
		msg1: '',
		msg2: '',
		second: false
	},
	watch: {
		msg(curVal) {
			if(/[^\d]/g.test(curVal)) {
				this.msg = this.msg.replace(/[^\d]/g, '');
			}
			if(curVal.length === 6) {
				if(!this.msg1) {
					this.msg1 = curVal;
					this.msg = '';
				} else {
					this.msg2 = curVal;
					this.checkTwoPsd();
				}
				console.log('this.msg=' + this.msg);
				console.log('this.msg1=' + this.msg1);
				console.log('this.msg2=' + this.msg2);
			}

		}
	},
	created() {
        if(localStorage.getItem('registered') || localStorage.getItem('registering')) {
            window.history.forward();
		}
	},
	computed:{
		notice: function() {
			if(this.msg1) {
				return '请再次输入密码';
			}
			return '请设置6位数字支付密码'
		}
	},
	methods: {
		focus() {
			this.$refs.pwd.focus();
		},
		checkTwoPsd() {
			if(this.msg1 !== this.msg2) {
				this.$toast('两次输入密码不一致!')
				this.msg1 = "";
				this.msg2 = "";
				this.msg = "";
			} else {
				this.$toast('两次输入密码一致!');
				localStorage.setItem('registering', '1');
				sessionStorage.clear();
				utils.jump('index');
			}
		}
	}
});